import axios from 'axios'
// import store from '../store';

//创建实例
const server = axios.create({
    baseURL: "http://110.41.83.104:3000",
    timeout: 30000,
    header: {
        'Content-Type': 'application/json'
    }
})

//请求拦截
// 添加请求拦截器，在请求头中加token
server.interceptors.request.use(
    (config) => {
        //本地存储token
        // config.headers.Authorization = window.localStorage.getItem('token');

        //Vuex管理
        // const token = store.state.user.token;
        // token && (config.headers.Authorization = token);
        return config;
    },
    (err) => {

        Promise.reject(err);
    }
)

//响应拦截
server.interceptors.response.use(
    (res) => {

        return res;
    },
    (err) => {
        Promise.reject(err);
    }
)

export default server;